package test.扩展函数

/*
    在你无法接触某个类定义，或者某个类没有使用open修饰符，导致你无法继承它时，扩展类就是增加类功能最好的选择
 */

/*
fun Any.easyPrint() = println(this)

fun main(args: Array<String>) {
    val str: String? = "张三"
    //str是否为空
    val myIsEmpty = str?.myIsEmpty()
    println(myIsEmpty)

    val addExt = str?.addExt(10)
    println(addExt)
S
}

fun String.myIsEmpty(): Boolean {
    return this == null || this.isEmpty()
}

fun String.addExt(amount: Int = 1) = this + "!".repeat(amount)

*/
